function broadcast(componentTag, eventName, params) {
  console.log('进入bradcast');
  console.log('componentTag', componentTag);
  console.log('eventName', eventName);
  console.log('params', params);
  this.$children.forEach(child => {
    console.log('child', child);
    var name = child.$options._componentTag;
    console.log('name', name);
    if (name === componentTag) {
      child.$emit.apply(child, [eventName].concat(params));
    } else {
      broadcast.apply(child, [componentTag, eventName].concat([params]));
    }
  });
}
export default {
  methods: {
    // dispatch(componentTag, eventName, params) {
    //   console.log('进入dispatch');
    //   console.log('componentTag', componentTag);
    //   console.log('eventName', eventName);
    //   console.log('params', params);
    //   var parent = this.$parent || this.$root;
    //   console.log('parent', parent);
    //   var name = parent.$options.componentTag;
    //   console.log('name', name);
    //   while (parent && (!name || name !== componentTag)) {
    //     parent = parent.$parent;

    //     if (parent) {
    //       name = parent.$options.componentTag;
    //     }
    //   }
    //   if (parent) {
    //     console.log('进入parent分支');
    //     parent.$emit.apply(parent, [eventName].concat(params));
    //   }
    // },



    // 改造版
    dispatch(componentTag, eventName, params) {
      console.log('进入dispatch');
      console.log('componentTag', componentTag);
      console.log('eventName', eventName);
      var parent = this.$parent.$parent.$parent
      console.log('parent', parent);
      console.log('eventName', eventName);
      console.log('params', params);
      parent.$emit.apply(parent, [eventName].concat(params));


      // while (parent) {

      //   parent = parent.$parent;

      //   console.log('parent3', parent);
      // }
    },
    broadcast(componentTag, eventName, params) {
      broadcast.call(this, componentTag, eventName, params);
    }
  }
};